//
//  LzwPartTableCell.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/2.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwPartTableCell.h"
#import "LzwBaseImageView.h"
#import "LzwBaseLable.h"
#import "UIImageView+WebCache.h"

@interface LzwPartTableCell()

@property (nonatomic, retain) LzwBaseImageView *myIamgePart;
@property (nonatomic, retain) LzwBaseImageView *myIamgePart1;

@property (nonatomic, retain) LzwBaseLable *myLablePart;
@property (nonatomic, retain) LzwBaseLable *myLablePart1;



@end
@implementation LzwPartTableCell

-(void)dealloc{
    [_myIamgePart release];
    [_myIamgePart1 release];
    [_myLablePart release];
    [_myLablePart1 release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self creatPart];
    }
    return self;
}

- (void)creatPart{
    
    //图片
    self.myIamgePart = [[LzwBaseImageView alloc]initWithFrame:CGRectMake(3 * WIDTH, 3 * WIDTH, 370 * WIDTH, 180 * WIDTH)];
    self.myIamgePart.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.myIamgePart];
    
    //喜爱图片
    self.myIamgePart1 = [[LzwBaseImageView alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 70 * WIDTH, 230 * WIDTH, 20 * WIDTH, 20 * WIDTH)];
    self.myIamgePart1.image = [UIImage imageNamed:@"love.png"];
    [self.contentView addSubview:self.myIamgePart1];
    
    //描述
    self.myLablePart = [[LzwBaseLable alloc]initWithFrame:CGRectMake(2 * WIDTH, 185 * WIDTH, 369 * WIDTH, 45 * WIDTH)];
    self.myLablePart.textColor = [UIColor lightGrayColor];
    self.myLablePart.font = [UIFont systemFontOfSize:16 * WIDTH];
    self.myLablePart.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLablePart];
    
    //喜爱人数
    self.myLablePart1 = [[LzwBaseLable alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 50 + 5 * WIDTH, 230 * WIDTH, 60 * WIDTH, 20 * WIDTH)];
    self.myLablePart1.textColor = [UIColor lightGrayColor];
    self.myLablePart1.font = [UIFont systemFontOfSize:16 * WIDTH];
    self.myLablePart1.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLablePart1];
    
    [_myIamgePart release];
    [_myIamgePart1 release];
    [_myLablePart release];
    [_myLablePart1 release];
    
}

-(void)setModlePart:(LzwPartModle *)modlePart{
    
    if (_modlePart != modlePart) {
        [_modlePart release];
        _modlePart = [modlePart retain];
    }
    
    self.myLablePart.text = self.modlePart.title;
    self.myLablePart1.text = self.modlePart.likes;
    
    NSURL *url = [NSURL URLWithString:self.modlePart.pic];
    
    [self.myIamgePart sd_setImageWithURL:url placeholderImage:nil];
    
}

@end
